﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using TileEngine.items;
using TileEngine.items.tiles.material;
namespace TileEngine.tiles.material
{
    class Cobalt : DefaultTile
    {
        public Cobalt(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public Cobalt()
        {
        }
        override public void draw(SpriteBatch spriteBatch,Point destinationPoint,Color tint)
        {
            int frame = 0;
            if(Global.currentWorld.tiles[x,y-1].tile.GetType() != typeof(Empty))
                frame += 8;
            if (Global.currentWorld.tiles[x + 1, y].tile.GetType() != typeof(Empty))
                frame += 4;
            if (Global.currentWorld.tiles[x, y + 1].tile.GetType() != typeof(Empty))
                frame += 2;
            if (Global.currentWorld.tiles[x - 1, y].tile.GetType() != typeof(Empty))
                frame += 1;
            spriteBatch.Draw(Textures.cobalt,new Rectangle(destinationPoint.X,destinationPoint.Y,20,20) ,
                new Rectangle((frame%4)*20,((int)(frame/4))*20,20,20), tint);
            //spriteBatch.DrawString(Textures.font8, x.ToString(), new Vector2(destinationPoint.X + 1, destinationPoint.Y), Color.Black);
            //spriteBatch.DrawString(Textures.font8, y.ToString(), new Vector2(destinationPoint.X + 1, destinationPoint.Y + 8), Color.Black);
        }
        override public bool breakTile()
        {
            Global.currentWorld.tiles[x, y].tile = new Empty(x,y);
            Global.currentWorld.items.Add(new CobaltItem(new Vector2(x*Global.tileSize.X, y*Global.tileSize.Y)));
            return true;
        }
        override public Type getItemType()
        {
            return typeof(CobaltItem);
        }
        override public Color getLight()
        {
            return Color.Black;
        }
        override public int getWidht()
        {
            return 0;
        }
        override public int getHeight()
        {
            return 0;
        }
        override public int getHardness()
        {
            return 10;
        }
        override public double getLightAbsorption()
        {
            return 0.7;
        }

    }
}
